package net.swl.linkedvillage;

import java.util.List;

import net.swl.linkedvillage.entity.Servico;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ServicosAdapter extends ArrayAdapter<Servico> {
	
	private List<Servico> items;

	public ServicosAdapter(Context context, int resource) {
		super(context, resource);
		// TODO Auto-generated constructor stub
	}
	
	public ServicosAdapter(Context context, int resource, List<Servico> items) {
		super(context, resource);
		this.items = items;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

	    View v = convertView;

	    if (v == null) {

	        LayoutInflater vi;
	        vi = LayoutInflater.from(getContext());
	        v = vi.inflate(R.layout.itemlistrow, null);

	    }

	    Servico p = items.get(position);

	    if (p != null) {

	        TextView tt = (TextView) v.findViewById(R.id.nome);
	        TextView tt1 = (TextView) v.findViewById(R.id.distancia);
	        
	        tt.setText(p.getPrestador().getUsername());
	        tt1.setText(p.getRaioAcao());

	        /*
	        if (tt != null) {
	            tt.setText(p.getId());
	        }
	        if (tt1 != null) {

	            tt1.setText(p.getCategory().getId());
	        }
	        if (tt3 != null) {

	            tt3.setText(p.getDescription());
	        }
	        */
	    }

	    return v;

	}
	
	

}
